package 力扣;

/**
 示例：
 给定二叉树 [3,9,20,null,null,15,7]，

  3
 / \
 9  20
 /  \
 15   7
 返回它的最大深度 3 。
 */
public class _104二叉树的最大深度 {
    public class TreeNode {
        int val;
       TreeNode left;
       TreeNode right;
        TreeNode() {}
        TreeNode(int val) { this.val = val; }
        TreeNode(int val,TreeNode left,TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }

    public int maxDepth(TreeNode root) {
        if( root == null ) return 0;
        int l = maxDepth(root.left);
        int r = maxDepth(root.right);
        return Math.max(l,r)+1;
    }
}
